 #查select
import pymysql
def select():
    conn = pymysql.connect(
        host='localhost',
        user='root',
        passwd='123456',
        db = 'aa',
        port=3306,
        charset='utf8'
        )

    cursor = conn.cursor()
    #SQL语句
    sql = "select name from test where age=''"
#执行语句
    cursor.execute(sql)
#获取查询数据
#ret = cursor.fetchone()
#ret = cursor.fetchmany(3)
    ret = cursor.fetchall() #
    if ret:
        print(1)
    else:
        print(0)
#关闭对象，连接
    cursor.close()
    conn.close()
#打印结果
select()